package com.qiniu.githubdata.frontend;

//import com.chat.utils.Result;
import com.qiniu.githubdata.common.Result;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/contributions")
public class ContributionController {

    @GetMapping("/{userId}/{year}")
    public Result<List<ContributionDTO>> getUserContributions(@PathVariable String userId, @PathVariable int year) {


        List<ContributionDTO> contributions = new ArrayList<>();
        
        // 模拟数据生成
        for (int day = 1; day <= 365; day++) {
            contributions.add(new ContributionDTO(
                String.format("%04d-%02d-%02d", year, (day - 1) / 30 + 1, (day - 1) % 30 + 1), 
                (int) (Math.random() * 10000)  // 随机步数
            ));
        }

        return Result.success(contributions);
    }
}
